<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <meta content="telephone=no" name="format-detection">
    <meta content="email=no" name="format-detection">
    <title>工单处理</title>
</head>

<body style="text-align: center">

    <div>
        版本号:<span id="version">...</span>
    </div>
    <button onclick="test()"> ddddddddd</button>
    <div id="time"></div>
    <script>
        //  console.log("connectWebViewJavascriptBridge")
        function connectWebViewJavascriptBridge(callback) {
            console.log("connectWebViewJavascriptBridge")
            if (window.WebViewJavascriptBridge) {
                callback(WebViewJavascriptBridge)
            } else {
                document.addEventListener(
                    'WebViewJavascriptBridgeReady',
                    function () {
                        callback(WebViewJavascriptBridge)
                    },
                    false
                );
            }
        }
        connectWebViewJavascriptBridge(function (bridge) {
            console.log("init ")
            bridge.init(function (message, responseCallback) {
                responseCallback(data);
            });

            //在这里注册方法供原生调用
            window.WebViewJavascriptBridge.registerHandler("tohtml"
                , function (data, responseCallback) {
                    console.log("registerHandler = " + data)
                    document.getElementById("time").innerText = (JSON.stringify(data))
                    responseCallback("这里是返回给原生的数据，如果不需要可以不写")
                })
        })
        function test() {

            //调用原生的方法
            window.WebViewJavascriptBridge.callHandler('test', {
                "params": { "dd": "dd" }
            }, function (data) {
                console.log(JSON.stringify(data))
                document.getElementById("time").innerText = (JSON.stringify(data))
            });
        }
    </script>
</body>


</html>